class Product:
    def __init__(self, name):
        self.name = name

    def get_name(self):
        return self.name


class ProductA(Product):

    def __init__(self, name):
        super().__init__(name)


class ProductB(Product):

    def __init__(self, name):
        super().__init__(name)


class ProductFactory:

    @staticmethod
    def create_product(product_type, name):

        if product_type == "A":
            return ProductA(name)

        elif product_type == "B":
            return ProductB(name)
        else:
            raise ValueError("Invalid product type")


# 使用对象工厂创建不同类型的产品对象

product_factory = ProductFactory()
product_a = product_factory.create_product("A", "Apple").get_name()
product_b = product_factory.create_product("B", "Banana").get_name()

print(product_a)
print(product_b)
'''
Apple
Banana
'''